<div id="login-form">
    <form>
        <h3>Sign in with your site user account</h3>
        <div>
            <label>Email</label>
            <input type="text" id="loginEmail" />
        </div>
        <div>
            <label>Password</label>
            <input type="password" id="loginPassword" />
        </div>
        <div id="login-messages"> </div>
        <div>
            <input type="button" value="Login" onclick="onLogin()" />
        </div>    
    </form>
</div>

<div style="clear:both"> </div>

<script type="text/javascript">
        function onLogin() {
            var email = $('#loginEmail').val();
            var password = $('#loginPassword').val();
            if (email == '') {
            	Vosao.errorMessage('#login-messages', 'Email is empty!');
            }
            else {
            	Vosao.jsonrpc.loginFrontService.login(function (r, e) {
                    if (Vosao.serviceFailed(e)) return;
                    if (r.result == 'success') {
                        $('#login-messages').html('<span style="color:green">Success. Logging in...</span>');
                        document.location.href = r.message;
                    }
                    else {
                        $('#login-messages').html('<span style="color:red">' 
                                + r.message + '</span>');
                    }
                }, email, password);
            }                
        }
</script>
